<?php
class documentDeleteAction extends sfActions
{
    public function execute($request)
    {
        $path_files = "";
    	$document_id = $request->getParameter('document_id');
        $this->forward404Unless($document = Doctrine_Core::getTable('VTNSDocument')->find($document_id), sprintf('Object document does not exist (%s).',$document_id));
        if(isset($document->file) && $document->file != null) {
             $path_files =  "uploads/document/".$document->file;
        }
        try {
             if(file_exists($path_files))
                 unlink($path_files);
             $document->delete();
        } catch (sfException $e) {
				echo $e->getMessage();
        }
       $this->redirect('document/documentList?document_category_id='.$document->document_category_id);
    	return sfView::SUCCESS;
    }
}
?>